package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.QuestionAdminPageQuery;
import com.tianji.learning.domain.vo.QuestionAdminVO;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/questions")
@RequiredArgsConstructor
@Api(tags = "互动问答-管理端端-问题相关接口")
public class InteractionQuestionAdminController {
    private final IInteractionQuestionService questionService;

    /**
     * 分页查询互动问题
     */
    @GetMapping("page")
    @ApiOperation("分页查询互动问题")
    public PageDTO<QuestionAdminVO> pageQueryAdmin(QuestionAdminPageQuery query){
        return questionService.pageQueryAdmin(query);
    }
    /**
     * 6、根据ID查询互动问题
     * @param id
     */
    @ApiOperation("根据ID查询互动问题")
    @GetMapping("/{id}")
    public QuestionAdminVO queryQuestionByIdAdmin(@PathVariable("id") Long id) {
    return questionService.queryQuestionByIdAdmin(id);
    }

    /**
     * 7、管理端隐藏或显示问题
     * @param id
     * @param hidden
     */

    @ApiOperation("隐藏或显示问题")
    @PutMapping("/{id}/hidden/{hidden}")
    public void hiddenQuestion(
            @ApiParam(value = "问题id", example = "1") @PathVariable("id") Long id,
            @ApiParam(value = "是否隐藏，true/false", example = "true") @PathVariable("hidden") Boolean hidden
    ) {
        questionService.updateQuestionHidden(id, hidden);
    }



}
